﻿@model GPS.ENTITYS.ViewModelSHANGDT_MONHOC
@using PagedList.Mvc;
@using GPS.Helpers;
@{
    ViewBag.Title = "Danh mục hạng đào tạo môn học";
}

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/jquery.maskedinput.js"></script>
<script src="~/Scripts/datepicker.js"></script>
<style>
    .table > thead {
        border: 1px solid #FF6600 !important;
        background-color: #F06F2B !important;
        color: white;
        align-items: center;
    }

        .table > thead > tr > th {
            color: #FCFFFF;
            cursor: pointer;
            white-space: nowrap;
            padding: 4px 6px 5px;
            border: 1px solid #F49462;
            overflow: hidden;
            font-weight: bold;
            text-align: center;
        }
</style>
<div class="container fdb-div-content fdb-div-corner-all">
    <h3 class="text-center fdb-title-search-form">danh mục hạng đào tạo môn học</h3>
    @using (Html.BeginForm("Index", "GPS_HangDT_MonHoc", FormMethod.Get))
    {
        <div class="row">
            <div class="list-group">
                <fieldset class="fs_body">
                    <legend class="head_title">Điều kiện tìm kiếm</legend>
                    <input type="hidden" id="CheckUser" value="@ViewBag.checkuser" />
                    <div class="criteria_search">
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Mã môn học:
                            </div>
                            <div class="col-md-4 control-txt">
                                @Html.TextBoxFor(model => model.pDTMONHOC_MA, new { @class = "form-control" })
                            </div>
                            <div class="col-md-2 control-label">
                                Tên môn học:
                            </div>
                            <div class="col-md-4 control-txt">
                                @Html.TextBoxFor(model => model.pDTMONHOC_TEN, new { @class = "form-control" })
                            </div>
                        </div>
                        <div class="row margin-top-05">
                            <div class="col-md-2 control-label">
                                Hạng đào tạo:
                            </div>
                            <div class="col-md-4 control-txt">
                                @Html.DropDownListFor(model => model.pDTMONHOC_HANGDT_MA, (SelectList)ViewBag.lstHangDT, "-- Lựa Chọn --", new { @class = "form-control", @id = "GV_HANGDT_MA_dll" })
                            </div>
                            <div class="col-md-2 control-label">
                                Trạng thái:
                            </div>
                            <div class="col-md-4 control-txt">
                                @Html.DropDownListFor(model => model.pDTMONHOC_ACTIVE, new List<SelectListItem>
                                {
                                    new SelectListItem() {Text = "--Lựa Chọn--", Value=""},
                                    new SelectListItem() {Text = "Không hiệu lực", Value="0"},
                                    new SelectListItem() {Text = "Hiệu lực", Value="1"}
                                }, new { @class = "form-control" })
                            </div>
                        </div>
                    </div>
                    <div class="row margin-top-05 btn_search">
                        @Html.NoEncodeActionLink("<span class='glyphicon glyphicon-plus'></span> Thêm mới", "Thêm mới", "Create", "GPS_HangDT_MonHoc", null, htmlAttributes: new { @class = "btn btn-warning btn-sm", @id = "btnCreate" })
                        <button id="btnSearch" type="submit" class="btn btn-warning btn-sm">
                            <span class="glyphicon glyphicon-search"></span> Tìm kiếm
                        </button>
                    </div>
                </fieldset>
            </div>

            <div class="row">
                <fieldset class="fs_body">
                    <legend class="head_title">Kết quả tìm kiếm</legend>
                    <div class="divbtnFielset">
                        <div style="float: right;">
                            <label id="lblMessageTotal" style="color:blue; font-weight:bold">Tổng số bản ghi: @ViewBag.TotalRow</label>
                        </div>
                    </div>
                    <div style="clear:both; padding: 5px 0;">
                        <table class="table table-hover table-bordered table-condensed">
                            <thead>
                                <tr>
                                    <th rowspan="2" style="line-height: 42px;">
                                        STT
                                    </th>
                                    <th rowspan="2" style="line-height: 42px;">
                                        Mã môn học
                                    </th>
                                    <th rowspan="2" style="line-height: 42px;">
                                        Tên môn học
                                    </th>
                                    <th rowspan="2" style="line-height: 42px;">
                                        Hạng đào tạo
                                    </th>
                                    <th colspan="4">
                                        Giờ đào tạo
                                    </th>
                                    <th rowspan="2" style="line-height: 42px;">
                                        Tổng giờ
                                    </th>
                                    <th rowspan="2" style="line-height: 42px;">
                                        Thao tác
                                    </th>
                                </tr>
                                <tr>
                                    <th>
                                        LT
                                    </th>
                                    <th>
                                        TH
                                    </th>
                                    <th>
                                        TD
                                    </th>
                                    <th>
                                        KT
                                    </th>
                                </tr>
                            </thead>
                            @{
        if (Model.SearchResults != null)
        {
            foreach (var item in Model.SearchResults)
            {
                <tr>
                    <td align="center">
                        @Html.DisplayFor(modelItem => item.STT)
                    </td>
                    <td align="center">
                        @Html.DisplayFor(modelItem => item.DTMONHOC_MA)
                    </td>
                    <td align="left">
                        @Html.DisplayFor(modelItem => item.DTMONHOC_TEN)
                    </td>
                    <td align="center">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_HANGDT_MA))
                    </td>
                    <td align="right">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_GIOLT))
                    </td>
                    <td align="right">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_GIOTHHINH))
                    </td>
                    <td align="right">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_GIOTHDUONG))
                    </td>
                    <td align="right">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_KIEMTRA))
                    </td>
                    <td align="right">
                        @Html.DisplayFor(modelItem => (item.DTMONHOC_TONGGIO))
                    </td>
                    <td align="center">
                        <a href="@Url.Action("Detail", "GPS_HangDT_MonHoc", new { id = item.DTMONHOC_MA, id1 = item.DTMONHOC_HANGDT_MA })" data-modal="">
                            <img width="20" height="20" src="@Url.Content("~/fonts/icon/search_file.png")" title="Xem chi tiết hạng đào tạo môn học" />
                        </a>
                        @{
                if (ViewBag.checkuser == "40")
                {
                    <a id="btnEdit" href="@Url.Action("Edit", "GPS_HangDT_MonHoc", new { id = item.DTMONHOC_MA, id1 = item.DTMONHOC_HANGDT_MA })" data-modal="">
                        <img width="20" height="20" src="@Url.Content("~/fonts/edit_item.png")" title="Chỉnh sửa hạng đào tạo môn học" />
                    </a>
                            <a id="btnDelete" href="@Url.Action("Delete", "GPS_HangDT_MonHoc", new { id = item.DTMONHOC_MA, id1 = item.DTMONHOC_HANGDT_MA })" onclick="return confirm('Bạn thật sự muốn xóa môn học và hạng đào tạo này!')">
                                <img width="20" height="20" src="@Url.Content("~/fonts/DELETE.GIF")" title="Chỉnh sửa hạng đào tạo môn học" />
                            </a>
                }
                        }

                    </td>
                </tr>
            }
        }
                            }

                        </table>
                    </div>

                    <div class="pagination-sm" style="clear:both; padding: 5px 0;">
                        @Html.PagedListPager(Model.SearchResults, page => Url.Action("Index", new
   {
       page,
       Model.pDTMONHOC_MA,
       Model.pDTMONHOC_TEN,
       Model.pDTMONHOC_HANGDT_MA,
       Model.pDTMONHOC_ACTIVE
   }))
                    </div>
                </fieldset>
            </div>
        </div>
    }
</div>


<!-- delete modal placeholder-->
<div id='deleteModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='deleteModalContent'></div>
        </div>
    </div>
</div>

<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/modalform")
}
<script type="text/javascript">
    $(document).ready(function () {
        // check user
        var _var = $("#CheckUser").val();
        if (_var != '40' && _var != null && _var != "") {
            $("#btnCreate").hide();
            $("#btnEdit").hide();
            $("#btnDelete").hide();
        } else {
            $("#btnCreate").show();
            $("#btnEdit").show();
            $("#btnDelete").show();
        }
        $("input").bind("keydown", function (event) {
            // track enter key
            var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
            if (keycode == 13) { // keycode for enter key
                // force the 'Enter Key' to implicitly click the Update button
                document.getElementById('btnSearch').click();
                return false;
            } else {
                return true;
            }
        });
    });
</script>

